<?PHP
require_once WACT_ROOT.'controller/controller.inc.php';
require_once APP_ROOT.'view/pub/layoutright.view.php';
require_once APP_ROOT.'model/common/session.php';
require_once APP_ROOT.'model/common/user.php';
require_once APP_ROOT.'model/common/player.php';
require_once APP_ROOT.'model/common/date.php';
require_once APP_ROOT . "model/common/site.php";


class PlayersPrintDetailView extends View {
	function PlayersPrintDetailView($TemplateFile){
		parent::View($TemplateFile);

	}

	function prepare(&$controller, &$request, &$responseModel){
		parent::prepare(&$controller, &$request, &$responseModel);
		$docbase="http://".$_SERVER['HTTP_HOST'];
		$this->Template->set('docbase',$docbase);

		$player_id=$request->getParameter('id');

		$player=&Player::getRecord($player_id);

 
        
		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());
		$this->Template->set('title',Site::getTitle().' - Print player profile -'.$player->get('name'));

		$datestr=$player->get('date_added');
		$mydate=strtotime($datestr);
        $tz =& new MyTimeZone();
        $mydate = $tz->timeGMT($mydate);
		$datestr = gmstrftime('%b %d, %Y',$mydate);
		$this->Template->set('date_added',$datestr);

		$prem=$player->get('premium');
		if($prem&&$prem==0) $prem=null;
		$this->Template->set('prem',$prem);

		$this->Template->set('name',$player->get('name'));
		$this->Template->set('class',$player->get('class'));

		// height/weight
		$height=$player->get('height');
		$weight=$player->get('weight');

		if($height) {
			$heightweight=$height.'/';
			if($weight) $heightweight.=$weight;
			$this->Template->set('heightweight',$heightweight);
		}else if($weight) {
			$heightweight='/'.$weight;
			$this->Template->set('heightweight',$heightweight);
		}

		$position=$player->get('position');
		if($position)$this->Template->set('position',$position);

		$category1=$player->get('category1');
		$category2=$player->get('category2');

		//categories
		if($category1) {
			$category=$category1;
			if($category2)	$category.='/'.$category2;
			$this->Template->set('category',$category);
		} else if($category2){
			$this->Template->set('category',$category2);
		}

		//school
		$school=$player->get('school_name');
		if($school)$this->Template->set('school_name',$school);

		$location=null;
		$saddress=$player->get('school_address');
		$scity=$player->get('school_city');
		$sstate=$player->get('school_state');
		$szip=$player->get('school_zip');
		$sphone=$player->get('school_phone');
		if($saddress) {
			$this->Template->set('school_address',$saddress);
			$location=' ';
		}
		if($scity) $location=$scity;
		if($sstate&&$sstate!='(N') $location.=', '.$sstate;
		if($szip) $location.=' '.$szip;
		if($location&&$location!=' ')
			$this->Template->set('school_lastaddress',$location);
		if($sphone) {
			$location='Phone: '.$sphone;
			$this->Template->set('school_phone',$location);
		}
		if($location)$this->Template->set('school_location',true);

		$img=$player->get('photo_url');
		if($img) $this->Template->set('photo_url',$img);

		//coach

		$coach_name=$player->get('coach_name');
		$coach_phone=$player->get('coach_phone');
		if($coach_name){
			$coach=$coach_name;
			if($coach_phone) 	$coach.=', '.$coach_phone;
			$this->Template->set('coach',$coach);
		}

		$gpa=$player->get('gpa');
		if($gpa) $this->Template->set('gpa',$gpa);
		$sat=$player->get('sat');
		if($sat) $this->Template->set('sat',$sat);

		$team=$player->get('team');
		if($team) $this->Template->set('team',$team);

		$projected_level=$player->get('projected_level');
		if($projected_level&&$projected_level!='')
			$this->Template->set('projected_level',$projected_level);
		$why_official_list=$player->get('why_official_list');
		if($why_official_list&&$why_official_list!='')
			$this->Template->set('why_official_list',$why_official_list);
		$description=$player->get('description');
		if($description&& $description!='')
			$this->Template->set('description',$description);


	}

}



class PlayersPrintDetailPage extends PageController{
	function PlayersPrintDetailPage() {
		parent::PageController();
        $site_id = Site::getTemplateSiteID();
        $mytemplate1 = 'pub/players/print_teaser.html';
        if ( $site_id == 1)
            $mytemplate1 = 'pub/players/print_teaser.html';
		$this->setDefaultView(new PlayersPrintDetailView($mytemplate1));

	}

}




?>
